import type { Student } from './student'
import http from '@/utils/http'

export interface Lesson {
  id: string
  title: string
  classId: string
  classroomId: string
  campusId: string
  leadTeacherId: string
  assistTeacherId?: string
  lessonIndex: number
  lessonDate: string
  startTime: string
  endTime: string
  lessonStatus: number
  arrangeLessonId?: string
  description?: string
  remark?: string
}

export interface ClassLessonResp extends Lesson {
  campusName?: string
  classroomName?: string
  weekName: string
}

export interface LessonStudent {
  id: string
  enrollmentId: string
  lessonClassId: string
  studentClassId: string
  lessonId: string
  studentId: string
  studentClassStatus: number
  signInTime?: string
  signInStatus: boolean
  studentJoinType: number
  lessonHour: number
  lessonPrice: number
  orderItemId: string
  remark: string
}

export interface LessonStudentDetailResp extends LessonStudent {
  student: Student
}

// 课次详情信息
export interface ClassLessonDetailResp extends ClassLessonResp {
  className: string

  normalStudentList: LessonStudentDetailResp[]
  changeStudentList: LessonStudentDetailResp[]
  changeClassOutStudentList: LessonStudentDetailResp[]
  changeLessonOutStudentList: LessonStudentDetailResp[]
  cancelStudentList: LessonStudentDetailResp[]
  totalStudentCount: number
  attendanceStudentCount: number
  changeClassInStudentCount: number
  changeLessonInStudentCount: number
  changeClassOutStudentCount: number
  changeLessonOutStudentCount: number
  changeStudentCount: number
  cancelStudentCount: number
  attendanceRate: number
}

export interface SignInReq {
  lessonId: string
  studentIdList: string[]
}

// 班级排课信息
export function getClassLessonDetail(lessonId: string) {
  return http.get<ClassLessonDetailResp>(`/t/lesson/detail/${lessonId}`)
}

export function getClassLessonList(classId: string) {
  return http.get<ClassLessonResp[]>(`/t/lesson/list/${classId}`)
}

// 点名
export function signIn(req: SignInReq) {
  return http.post(`/t/lesson/signIn`, req)
}

// 撤销点名
export function unSignIn(req: SignInReq) {
  return http.post(`/t/lesson/unSignIn`, req)
}
